package br.com.web.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.transaction.annotation.Transactional;

import br.com.web.dominio.Arquivo;

@Transactional
public class ArquivoDAOImpl implements ArquivoDAO {
	private EntityManager em;
	public ArquivoDAOImpl(){}
	
	@PersistenceContext
    public void setEntityManager(EntityManager em) {
        this.em = em;
    }
	
	public EntityManager getEntityManager() {
        return (em);
    }
	
	@Override
	public void salvar(Arquivo arquivo) {		
		em.persist(arquivo);
	}
	
	@Override
	public List<Arquivo> getArquivos(){
		Query query = em.createQuery("select a from Arquivo a");
		return (query.getResultList());
	}
}
